/**
  ******************************************************************************
  * @file    Queue.h 

  ******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __QUEUE_H
#define __QUEUE_H

#ifdef  __cplusplus
extern "C" {
#endif		/* __cplusplus */

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"


#pragma pack(1)
/**
 * @struct	_QBuf
 * @brief	QBuffer structure define
 */
typedef struct _QBuf {
	unsigned short head;	///< head point
	unsigned short tail;	///< tail point
	char *buf;				///< circular buffer
	unsigned short len;		///< buffer length
	unsigned short use;		///< usage of buffer
}QBuf;

/** @name QBUFFER ERROR CODE DEFINE
 * @{
 */
#define QBUF_OK			(0)	///< qbuffer operation ok
#define QBUF_FULL		(1)	///< qbuffer full
#define QBUF_EMPTY		(2)	///< qbuffer empty
/** @} */


extern void QBuf_Init(QBuf *q, char *buf, unsigned short len);
extern unsigned char QBuf_Write(QBuf *q, char *buf, unsigned short len);
extern unsigned char QBuf_Read(QBuf *q, char *buf, unsigned short len);
extern unsigned char QBuf_Del(QBuf *q, unsigned short len);
extern void QBuf_Clear(QBuf *q);
extern unsigned char QBuf_ChkFull(QBuf *q,unsigned short len);


#define CON_RX_BUF_SIZE 256 

/* Exported types ------------------------------------------------------------*/


/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

#ifdef __cplusplus
}
#endif	/* __cplusplus */
#endif /* __QUEUE_H */

/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
